package com.my.autoassociate.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.gitee.mayan50.autoassociate.annotation.OneToOne;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.apache.ibatis.annotations.One;

@Data
@Accessors(chain = true)
@ToString
public class User {

    @TableId(type = IdType.AUTO)
    private Long id;
    private String name;
    private Integer age;
    private Long piratesId;

    @TableField(exist = false)
//    @OneToOne(column = "pirates_id", associateColumn = "id")
    @OneToOne(sql = "SELECT * FROM `pirates` WHERE id = ?", condition = "a:pirates_id")
    private Pirates pirates;

}
